package com.ruoyi.eservice.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.eservice.pojo.entity.NoticePlace;
import com.ruoyi.eservice.service.INoticePlaceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 核酸点Controller
 *
 * @author ruoyi
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/eservice/place")
public class NoticePlaceController extends BaseController
{
    @Autowired
    private INoticePlaceService noticePlaceService;

    /**
     * 查询核酸点列表
     */
    @PreAuthorize("@ss.hasPermi('eservice:place:list')")
    @GetMapping("/list")
    public TableDataInfo list(NoticePlace noticePlace)
    {
        startPage();
        List<NoticePlace> list = noticePlaceService.selectNoticePlaceList(noticePlace);
        return getDataTable(list);
    }

    /**
     * 导出核酸点列表
     */
    @PreAuthorize("@ss.hasPermi('eservice:place:export')")
    @Log(title = "核酸点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NoticePlace noticePlace)
    {
        List<NoticePlace> list = noticePlaceService.selectNoticePlaceList(noticePlace);
        ExcelUtil<NoticePlace> util = new ExcelUtil<NoticePlace>(NoticePlace.class);
        util.exportExcel(response, list, "核酸点数据");
    }

    /**
     * 获取核酸点详细信息
     */
    @PreAuthorize("@ss.hasPermi('eservice:place:query')")
    @GetMapping(value = "/{noticePlaceId}")
    public AjaxResult getInfo(@PathVariable("noticePlaceId") Long noticePlaceId)
    {
        return AjaxResult.success(noticePlaceService.selectNoticePlaceByNoticePlaceId(noticePlaceId));
    }

    /**
     * 新增核酸点
     */
    @PreAuthorize("@ss.hasPermi('eservice:place:add')")
    @Log(title = "核酸点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NoticePlace noticePlace)
    {
        return toAjax(noticePlaceService.insertNoticePlace(noticePlace));
    }

    /**
     * 修改核酸点
     */
    @PreAuthorize("@ss.hasPermi('eservice:place:edit')")
    @Log(title = "核酸点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NoticePlace noticePlace)
    {
        return toAjax(noticePlaceService.updateNoticePlace(noticePlace));
    }

    /**
     * 删除核酸点
     */
    @PreAuthorize("@ss.hasPermi('eservice:place:remove')")
    @Log(title = "核酸点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticePlaceIds}")
    public AjaxResult remove(@PathVariable Long[] noticePlaceIds)
    {
        return toAjax(noticePlaceService.deleteNoticePlaceByNoticePlaceIds(noticePlaceIds));
    }
}
